package webgamemaker.Editor;

import java.util.ArrayList;

import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;

public class DirData 
{
	public ArrayList<String> dir;
	public ArrayList<String> file;
	
	public DirData()
	{
		dir = new ArrayList<String>();
		file = new ArrayList<String>();
	}
	
	public DirData(JSONValue value)
	{
		this();
		setValue(value);
	}
	
	public void setValue(JSONValue value)
	{
		JSONObject obj = value.isObject();
		JSONArray dir = obj.get("dir").isArray();
		JSONArray file = obj.get("file").isArray();
		if(dir != null && file != null)
		{
			for(int i = 0; i < dir.size(); i++)
				this.dir.add(dir.get(i).isString().stringValue());
			for(int i = 0; i < file.size(); i++)
				this.file.add(file.get(i).isString().stringValue());
		}
		else throw new RuntimeException(obj.get("error").isString().stringValue());
	}
}
